package cn.dnuifood_cjy.dnuifood_16110100529.model;

import cn.dnuifood_cjy.dnuifood_16110100529.iface.UserIface;
import cn.dnuifood_cjy.dnuifood_16110100529.listener.OnRetrofitListener;
import cn.dnuifood_cjy.dnuifood_16110100529.service.UserService;
import retrofit2.Call;

public class UserModel extends RetrofitBaseModel implements UserIface {
    private UserService userService;

    public UserModel() {
        this.userService = retrofit.create(UserService.class);
    }

    public void login(String username, String password, final OnRetrofitListener listener) {
        Call call = userService.doLogin(username, password);
        bindCallback(call, listener, Constants.USERLOGIN);
    }

    public void reg(String username, String userpass, String mobilenum, String address, String comment, final OnRetrofitListener listener) {
        Call call = userService.doRegister(username, userpass, mobilenum, address, comment);
        bindCallback(call, listener, Constants.USERREGISTER);
    }

    public void getUserById(String user_id, final OnRetrofitListener listener) {
        Call call = userService.getUserById(user_id);
        bindCallback(call, listener, Constants.GETFOODBYSHOP);
    }


    public void updateUserById(String user_id, String username, String userpass, String mobilenum, String address, final OnRetrofitListener listener) {
        Call call = userService.updateUserById(user_id, username, userpass, mobilenum, address);
        bindCallback(call, listener, Constants.GETFOODBYSHOP);
    }

    public class Constants {
        public final static String BASE_URL = "http://172.24.10.175:8080/foodService/";
        public final static int USERLOGIN = 1;
        public final static int USERREGISTER = 2;
        public final static int GETFOODBYSHOP = 3;
        public final static int ISCOLLECTED = 4;
        public final static int USERCOLLECTFOOD = 5;

    }
}
